<script setup lang="ts">
  import { InputWrappedRef } from 'naive-ui/es/input/src/interface'

  defineOptions({
    name: 'MyInput'
  })
  import { InputInst, NInput } from 'naive-ui'
  import { ComponentInstance, h, type UnwrapRef } from 'vue'
  import MyInput from '@/components/MyInput/index.vue'

  const vm = getCurrentInstance()

  const changeRef = (exposed: Element | ComponentPublicInstance | null) => {
    if (vm) {
      vm!.exposeProxy = vm!.exposed = exposed || {}

      console.log('exposed', exposed)

      // vm!.exposeProxy = vm!.exposed = {
      //   ...exposed,
      //   test: () => {
      //     console.log('test')
      //   }
      // }
      // vm.exposed.test = () => {
      //   console.log('test')
      // }
    }
  }
  export type MyInputInst = InputInst & {
    test: () => void
  }
  defineExpose<MyInputInst>({} as ComponentInstance<typeof MyInput>)
</script>

<template>
  <component :is="h(NInput, { ...$attrs, ref: changeRef }, $slots)"></component>
</template>

<style scoped lang="less"></style>
